﻿using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using LinqDll;

namespace LinqBll.Cores
{
    public class AwardCore : BaseCore<Activity_Awards>
    {
        public AwardCore(DataContext dataContext)
            : base(dataContext)
        {
        }

        public Activity_Awards GetAwards(int awardId)
        {
            return base.Table.FirstOrDefault(s => s.Id == awardId && s.status && s.isDel == false);
        }

        public List<Activity_Awards> GetAwardsByCycle(int cycleId)
        {
            return Table.Where(s => s.cycleId == cycleId && s.status && s.isDel == false).ToList();
        }

        public List<Activity_Awards> GetAwardsBySponsor(int? sponsorId)
        {
            List<Activity_Awards> list;

            if (sponsorId.HasValue)
                list = Table.Where(s => s.sponsorId == sponsorId).ToList();
            else
                list = Table.Where(s => s.sponsorId == null).ToList();
            return list;
        }
    }
}